<!DOCTYPE html>
<html lang="en"
      xmlns:th="http://www.thymeleaf.org"
      xmlns:sec="http://www.thymeleaf.org/extras/spring-security">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1"/>
    <title>登录页面</title>
    <link rel="stylesheet" th:href="@{/plugins/bootstrap/css/bootstrap.css}" />
    <link rel="stylesheet" th:href="@{/plugins/bootstrap/css/bootstrap-theme.css}" />
</head>
<body>
<body>
    <div class="container">
        <form class="form-horizontal">
            <div class="form-group">
                <div class="col-sm-4 col-sm-offset-4">
                    <input class="form-control" type="text" name="username" placeholder="请输入账号" autocomplete="off"
                        value="admin"/>
                </div>
            </div>

            <div class="form-group">
                <div class="col-sm-4 col-sm-offset-4">
                    <input class="form-control"  type="password" name="password" placeholder="请输入密码" autocomplete="off"
                        value="admin"/>
                </div>
            </div>

            <div class="form-group">
                <div class="col-sm-4 col-sm-offset-4">
                    <button type="button" name="loginBtn" lay-filter="submitBtn"
                            class="btn btn-info form-control">登录</button>
                </div>
            </div>
        </form>
    </div>
<script th:src="@{/plugins/bootstrap/js/jquery.min.js}"></script>
<script th:src="@{/plugins/js/axios.min.js}"></script>
<script th:src="@{/plugins/bootstrap/js/bootstrap.js}"></script>
<script>
    $(function () {
       $('button[name=\'loginBtn\']').click(function () {
            var formData = $('form').serialize();
            $.post('/authentication/form', formData, function (data) {
                console.log(JSON.stringify(data));
                if(data.flag){
                    window.location = '/';
                }else {
                    alert(data.msg);
                }
            });
        });
    });

</script>
</body>
</body>
</html>